home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / jazlib.arc / JZREDSCR.ASM < prev    next >
Assembly Source File  |  1988-12-18  |  3KB  |  101 lines

  1. Comment *
  2. ┌────────────────────────────────────────────────────────────────────────────┐
  3. │title     : jzredscr                                 │
  4. │Purpose : read directly from the screen buffer without snow             │
  5. │Notes     : Yes, even reading from the screen causes snow !!!             │
  6. │(C) JazSoft Software by Jack A. Zucker (301) 794-5950                 │
  7. └────────────────────────────────────────────────────────────────────────────┘
  8.  *
  9. title    print directly to screen buffer
  10. name    jzredscr
  11.  
  12.     assume cs:_text
  13. _text    segment public byte 'code'
  14.     public _jzredscr
  15.  
  16. _jzredscr     proc     near
  17.     push bp
  18.     mov bp,sp
  19.     push si
  20.     push di
  21.     push ds
  22.     push es
  23.     mov al,[bp+6]        ; get row
  24.     mov bx,50h        ; 50 columns (hex)
  25.     mul bl            ; row offset = # columns * row
  26.     mov bx,ax        ; put value back in bx
  27.     add bx,[bp+8]        ; add column
  28.     shl bx,1        ; multiply by 2
  29.     mov si,bx        ; screen seg:di = offset for writing
  30.  
  31.     mov cx,[bp+0Ah]     ; get length in cx
  32.  
  33.     push ds         ; save ds for mode check
  34.     mov ax,40h        ; low memory information segment
  35.     mov ds,ax
  36.     mov di,49h        ; screen mode
  37.     cmp byte ptr [di],7    ; 7 = mono mode
  38.     mov di,[bp+4]        ; get offset of first character
  39.     pop es            ; restore our data into dest segment
  40.     jz mono         ; [si] = 7 means mono mode
  41.     mov ax,0b800h        ; color screen segment
  42.     mov ds,ax
  43. next:
  44.     mov dx,3dah        ; address of 6845 Status register
  45.  
  46. Comment *
  47. ┌────────────────────────────────────────────────────────────────────────────┐
  48. │ This next section which only gets executed in color mode checks the status │
  49. │ register of the 6845 crt controller chip. When bit 0 is set to 1 we can    │
  50. │ update the screen without snow. The process is to check to see if it's set │
  51. │ to one and loop until it's not. Then loop until it's High and fall out of  │
  52. │ the loop and write the character. The reason it's done this way is in case │
  53. │ you initially check the status and it's at the very end of a retrace. In   │
  54. │ that case, you would think that it is safe to write to the screen buffer   │
  55. │ but my way takes care of a partially complete retrace on the first try.    │
  56. │ Examine the code on pertaining to bios int 9 in the Ibm technical reference│
  57. │ manual. Note that this code is unnecessary for many compatibles as they do │
  58. │ not have the same bug in their displays as the Ibm pc does.             │
  59. └────────────────────────────────────────────────────────────────────────────┘
  60.  *
  61.  
  62. status_low:
  63.     in al,dx        ; get vertical retrace status
  64.     ror al,1        ; faster than test
  65.     jc status_low        ; wait for partially done retrace
  66.     cli            ; don't allow any more interrupts
  67. status_high:
  68.     in al,dx        ; wait for beginning of new retrace
  69.     ror al,1
  70.     jnc status_high     ; retrace not started
  71.  
  72.     sti            ; interrupt allowed now
  73.     movsb            ; screen to string
  74.     inc si            ; point to next position (attribute)
  75.     loop next
  76.     jmp endofdsp
  77.  
  78. mono:
  79.     mov ax,0b000h        ; Mono screen segment
  80.     mov ds,ax
  81. next2:
  82.     movsb
  83.     inc si            ; point to next char position
  84.     loop next2
  85. endofdsp:
  86.     mov bh,0
  87.     mov es:[di],bh        ; c needs a zero terminating byte
  88.     mov cx,[bp+0Ah]     ; get length
  89.     sub di,cx        ;
  90.     mov ax,di        ; return pointer to destination string
  91.     pop es
  92.     pop ds
  93.     pop di
  94.     pop si
  95.     mov sp,bp
  96.     pop bp
  97.     ret
  98. _jzredscr endp
  99. _text ends
  100. end
  101.